/*
 * F.java
 *
 * Created on 11/09/2007, 11:26:56
 *
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tcc.gui.web.struts.funcionario;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import tcc.applicationService.tccsystemuser.TccSystemUserAS;
import tcc.domain.login.TCCSystemUser;


public class RemoverFuncionarioAction extends Action {

    private static final String SUCCESS_FWD = "success";

    public RemoverFuncionarioAction() {
    }

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

        String idParam = request.getParameter("FuncionarioForm.funcionario.id");
        if (idParam != null) {

            Long id = Long.valueOf(idParam);
            FuncionarioForm funcionarioForm = (FuncionarioForm) form;
            funcionarioForm.getFuncionario().setId(id);
            TccSystemUserAS.getInstance().removerFuncionanrio(funcionarioForm.getFuncionario());
       
         }
    
        return mapping.findForward(SUCCESS_FWD);
    }
}